<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<link rel="stylesheet" type="text/css" href="gpfw_layout.css"
			media="all" />
		<link rel="stylesheet" type="text/css" href="gpfw_color.css"
			media="all">
		<link rel="stylesheet" type="text/css"
			href="css/gpfw_font-size_medium.css" media="all" />
		<link rel="stylesheet" type="text/css" href="gpfw_print.css"
			media="print" />
		<script type="text/javascript" src="gpfw.js">
</script>
		<script type="text/javascript" src="js/jquery-1.4.4.js"
			charset="utf-8">
</script>
		<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"
			charset="utf-8">
</script>
		<title>物品详细信息</title>
		<style type="text/css">
td {
	border: 1px solid black;
}
</style>
	</head>
	<body>
	<table class="azmainFrame" cellspacing="0" cellpadding="0">
  <tr>
    <td class="azgyom"><table class="azpalette" cellpadding="0" cellspacing="0">
  <tr>
    <td class="azpalette"><table class="aztileLarge" cellspacing="0" cellpadding="0">
  <tr>
    <td><table class="aztabSheetArea" id="ragSUBMIT1" name="ragSUBMIT1" cellpadding="0" cellspacing="0" style="display:inline-table;">
  
		<input type="hidden" id="goodsid" value="${goodHelper.id}">
		<table style="margin-top: 30px;">
			<tr>
				<td>
					<table style="margin-top: 5px;">
						<caption>
							物品详细信息
						</caption>
						<thead>
							<tr>
								<td width="200px;"></td>
								<td width="400px;"></td>
							</tr>
						</thead>
						<tr>
							<td>
								目的：
							</td>
							<td>
								<span style="font-weight:700;color:red;">${goodHelper.supplyordemand}</span>
							</td>
						</tr>
						<tr>
							<td>
								是否是竞拍商品
							</td>
							<td>
								<span style="font-weight:700;color:red;">${goodHelper.isJingpaiOrNot==0?'非竞拍商品':'竞拍商品'}</span>
							</td>
						</tr>
						
						<tr>
							<td>
								竞拍
							</td>
							<td>
								<span style="font-weight:700;color:red;">${goodHelper.canBeJingpaiNow==true?'可以参与竞拍':'不能参与竞拍'}</span>
							</td>
						</tr>
						<tr>
							<td>
								标题
							</td>
							<td>
								<span style="font-weight:700;color:black;">${goodHelper.title}</span>
							</td>
						</tr>
						<tr>
							<td>
								发布人
							</td>
							<td>
								${goodHelper.user.username}
							</td>
						</tr>
						<tr>
							<td>
								联系方式：
							</td>
							<td>
								${goodHelper.user.telephone}
							</td>
						</tr>
						<tr>
							<td>
								物品分类：
							</td>
							<td>
								${goodHelper.classify}
							</td>
						</tr>
						<tr>
							<td>
								发布时间：
							</td>
							<td>
								${goodHelper.publishTime}
							</td>
						</tr>
						<tr>
							<td>
								价格
							</td>
							<td>
								${goodHelper.price}
							</td>
						</tr>
						<tr>
							<td>
								详细描述
							</td>
							<td>
								${goodHelper.description}
							</td>
						</tr>
						<tr>
							<td colspan="2" id="goods_reply">
								
							</td>
						</tr>
						<tr>
							<td colspan="2">
								
							</td>
						</tr>
						<tr >
							<td colspan="2">
								<div>
									<div style="background-color: #ECE9D8;font-weight: 700;">回复信息发布者</div>
									<div id="div_input_price" style="display: none;">竞拍价格:<input type="text" id="input_price"/></div>
									<textarea class="aztxa" id="replyWords" name="txa" cols="60" rows="4"
										wrap="off"></textarea>
									<input type="button" class="azpbn" id="pbn" value="提交" name="pbn"
										onClick="addReply();">
								</div>
							</td>
						</tr>
					</table>
				</td>
				<td style="padding-top: 1px;">
					<div>
					<div style="background-color:#E1F0FA;font-weight:800;color:red;font-size:40px;text-align: center;">${goodHelper.soldOut==1?'已经售出':'未售出'}</div>
						<img style="width: 450px; height: 450px;" alt="sss"
							src="${goodHelper.photo2==null? 'image/error.jpg' : goodHelper.photo2}">
					</div>
				</td>
			</tr>
		</table>
		<script type="text/javascript">
			$(function(){
				getReply($("#goodsid").val());
				paipai();
			});
			function getReply(id){
				$.post("<%=path%>/json/acquireReplysByGoodsId.action",
					   {goodsId:id},
					   function(data){
						   for(var i=0;i<data.replyHelpers.length;i++){
							   $('<div style="background-color: #E1F0FA;border: 1px solid black;margin-top: 2px;">' +
							   '<span style="color:red">回复'+(i+1)+'</span>'+
							   '<br/>回复价格:'+data.replyHelpers[i].price+
							   '<br/>回复留言:'+data.replyHelpers[i].replyWords+
							   '<br/>回复时间:'+data.replyHelpers[i].replyTime+
							   '<br/>回复用户:'+data.replyHelpers[i].userName+
							   '</div>').appendTo("#goods_reply");
						   }
					   },
					   "json");
			}
			function addReply(){
				var price=$("#input_price").val();
				//整数正则表达式
				var pattern1=/^\d+$/;
				//浮点数正则表达式
				var pattern2=/^(\d+)(\.)(\d+)$/;
				var replyWords=$("#replyWords").val();
				if(pattern1.exec(price)||pattern2.exec(price) ||!price){
					
				}else{
					alert("请填入有效价格");
					return;
				}
				if(replyWords==null || replyWords==''){
					alert("请填入详细回复信息");
					return;
				}else{
				}
				var goodsId=$("#goodsid").val();
				$.post("<%=path%>/json/addReply.action",
				   {goodsId:goodsId,price:price,replyWords:replyWords},
				   function(data){
					   if(data.resultBoolean){
						   $("#goods_reply").html("");
						   getReply($("#goodsid").val());
						   $("#input_price").val("");
						   replyWords=$("#replyWords").val("")
					   }
					   alert(data.result);
				   },
				   "json");
			}
			function paipai(){
				var canBePaipai='${goodHelper.canBeJingpaiNow}';
				if(canBePaipai=='true'){
					$("#div_input_price").show();
				}
				
			}
		</script>
	</body>
</html>
